var webpack = require('webpack'),
    path = require('path'),
    ExtractTextPlugin = require("extract-text-webpack-plugin"),
    nodeModulesDir = path.join(__dirname, 'node_modules'),
    outputDirectory = path.join(__dirname, 'dist');

module.exports = {
  target: 'atom',
  entry: {
    app: './src/boot.js',
    vendors: ['lodash', 'jquery', 'moment', 'classnames', 'react', 'react-dom', 'react-router', 'flux', 'amazeui-react']
  },
  output: {
    path: outputDirectory,
    filename: '[name].bundle.js'
  },
  module:{
    loaders: [
      {test: /\.jsx?$/, loader: 'babel', exclude: /node_modules/, query: {presets: ['es2015', 'stage-0', 'react'], plugins: ['transform-runtime']}},
      {test: /\.styl$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader!stylus-loader")},
      {test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader")},
      {test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: {presets: ['es2015', 'stage-0'], plugins: ['transform-runtime']}},
      {test: /\.(png|jpg)$/, loader: "url?limit=2500"},
      {test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
      {test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff2"},
      {test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream"},
      {test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file"},
      {test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml"}
    ]
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}}),
    new webpack.optimize.OccurenceOrderPlugin(true),
    new webpack.optimize.CommonsChunkPlugin({name: 'vendors', filename: 'vendors.js'}),
    new ExtractTextPlugin('style.css')
  ]
}
